package com.woniuxy.springparking.controller;

import com.woniuxy.springparking.asepct.SysLog;
import com.woniuxy.springparking.common.RestDto;
import com.woniuxy.springparking.common.RestResult;
import com.woniuxy.springparking.service.MerchentUserService;
import com.woniuxy.springparking.vo.LogVO;
import com.woniuxy.springparking.vo.MerchentUserVo;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MerchantUserController {
    @Autowired
    private MerchentUserService merchentUserService;

    @GetMapping("/mUserSelectByPage.do")
    @ApiOperation(value = "分页查询所有商户基本信息",httpMethod = "GET",
            protocols = "HTTP",produces = "application/json",
            response = RestResult.class,notes = "分页查询所有商户信息")
    public RestResult list(MerchentUserVo mvo){
        return merchentUserService.findByPage(mvo);
    }

    @GetMapping("/mUserCheckSelectByPage.do")
    @ApiOperation(value = "分页查询所有商户认证信息",httpMethod = "GET",
            protocols = "HTTP",produces = "application/json",
            response = RestResult.class,notes = "分页查询所有商户认证信息")
    public RestResult check(MerchentUserVo mvo){
        return merchentUserService.findCheckByPage(mvo);
    }

    @PostMapping("/updateState.do")
    @ApiOperation(value = "更新商户账号状态",httpMethod = "POST",
            protocols = "HTTP",produces = "application/json")
    @SysLog(value1 = "更新",value2 = "更新商户账号状态")
    public void updateState(Integer state,Integer id){
         this.merchentUserService.updateState(state,id);
    }

    @PostMapping("/updateMState.do")
    @ApiOperation(value = "更新商户认证状态",httpMethod = "POST",
            protocols = "HTTP",produces = "application/json",
            response = RestDto.class,notes = "更新商户认证状态")
    @SysLog(value1 = "更新",value2 = "更新商户认证状态")
    public RestDto updateMState(String m_state, Integer id){
        RestDto dto = new RestDto();
            this.merchentUserService.updateMState(m_state,id);
            dto.setCode(200);
            dto.setMsg("");
        return dto;
    }
}
